<template>
<!-- 设计计划实施 -->
  <base-breadcrumb>
    <title-name title="搜索"></title-name>
    <!-- <template  v-slot:content>
      <div class="table-page-search-wrapper">
        <a-form  style="margin-top:20px">
          <a-row :gutter="24">
            <a-col :md="8" :sm="8">
              <a-form-item label="项目名称"
                           :labelCol="{lg: {span: 6}, sm: {span:6}}"
                           :wrapperCol="{lg: {span: 18}, sm: {span: 18} }">
                <BaseInput v-model="queryParam.designDemandName" placeholder=""/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="8">
            <a-form-item label="状态"
                           :labelCol="{lg: {span: 6}, sm: {span:6}}"
                           :wrapperCol="{lg: {span: 18}, sm: {span: 18} }">
                <a-select v-model="queryParam.status" placeholder="请选择" default-value="0">
                <a-select-option v-for="item in status" :key="item.id" :value="item.id">{{item.name}}</a-select-option>
                </a-select>
            </a-form-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <span class="table-page-search-submitButtons" >
                <a-button type="primary" @click="searchData">搜索</a-button>
                <a-button style="margin-left: 8px" @click="() => this.queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>
          </a-row>
          <template v-if="advanced">
            <a-row :gutter="24">
              <a-col :md="8" :sm="8">
                <a-form-item label="时间阶段"
                           :labelCol="{lg: {span: 6}, sm: {span:6}}"
                           :wrapperCol="{lg: {span: 18}, sm: {span: 18} }">
                  <a-select v-model="queryParam.time" placeholder="请选择" default-value="0">
                    <a-select-option v-for="item in company" :value="item.code" :key="item.code">{{item.name}}</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
            <a-col :md="8" :sm="8">
              <a-form-item label="分公司"
                           :labelCol="{lg: {span: 6}, sm: {span:6}}"
                           :wrapperCol="{lg: {span: 18}, sm: {span: 18} }">
                <BaseInput v-model="queryParam.projectName" placeholder=""/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-item label="项目设计管理类别"
                           :labelCol="{lg: {span: 6}, sm: {span:6}}"
                           :wrapperCol="{lg: {span: 18}, sm: {span: 18} }">
                <BaseInput v-model="queryParam.status" placeholder=""/>
              </a-form-item>
            </a-col>
            </a-row>
          </template>
        </a-form>
      </div>
    </template> -->
    
    <searchData :searchData="searchArr" @search="search"></searchData>
    <a-card :bordered="false" style="over-flow:scroll">
      <title-name title="设计计划列表"></title-name>
      <div>
        <a-row>
          <a-col :md="24" :sm="19">
            <div class="table-operator">
              
              <div class="pub-table-select-count">
                <a-icon type="info-circle" theme="twoTone"/>
                <span> 设计计划共{{ total.total }}项 </span>&nbsp;
                <span> 已完成{{ total.complete }}项  </span>
                <span> 未完成{{ total.notComplete }}项  </span>
              </div>
            </div>
            <s-table
                    ref="table"
                    size="default"
                    rowKey="row.id"
                    :columns="columns"
                    :data="loadData"
                    :alert="true"
                    show-size-changer
                    show-quick-jumper
                    :rowSelection="rowSelection"
                    showPagination="auto">
              <span slot="action" slot-scope="text, record">
                <template>
                <a @click="handleSub(record,'view')">查看</a>
                  <a-divider type="vertical"/>
                <a @click="handleEdit(record)">节点维护</a>
                </template>
              </span>
            </s-table>
          </a-col>
        </a-row>
      </div>
    
    </a-card>
  </base-breadcrumb>
</template>

<script>
  import { STable, Ellipsis } from '@/components'
  import { getEvaluateList  ,addEvaluateList,getEvaluateListTotal} from '@/api/evaluate'
  import { getdesignPlan ,getTotal, getnodeList } from '@/api/design/planConstruction'
  const searchArr = [
    // 搜索框
    {
      name: '项目名称',
      value: 'name',
      type: 'input'
    },
    {
      name: '状态',
      type: 'select',
      value: 'status',
      data: [
        {
          value: '0',
          label: '可用'
        },
        {
          value: '1',
          label: '不可用'
        }
      ]
    },
    {
      name: '时间阶段',
      value: 'recommendSubcontractors',
      type: 'input'
    },
    {
      name: '分公司',
      value: 'recommendSubcontractors',
      type: 'input'
    },
    {
      name: '项目设计管理类别',
      type: 'select',
      value: 'designType',
    },
  ]
  const columns = [
    {
      title: '序号',
      scopedSlots: { customRender: 'serial' }
    },
    {
      title: '项目名称',
      dataIndex: 'name'
    },
    {
      title: '项目业态',
      dataIndex: 'format',
    },
    {
      title: '项目设计管理类别',
      dataIndex: 'designType',
    },
    {
      title: '分公司',
      dataIndex: 'branchCompany',
    },
    {
      title: '立项时间',
      dataIndex: 'time',
    },
    {
      title: '设计节点总数',
      dataIndex: 'nodeTotal',
    },
    {
      title: '已完成节点总数',
      dataIndex: 'completeNode',
    },
    {
      title: '待完成节点总数',
      dataIndex: 'time',
    },
    {
      title: '完成度',
      dataIndex: 'notCompleteNode',
    },
    {
      title: '状态 ',
      dataIndex: 'status',
    },
    {
      title: '操作',
      dataIndex: 'action',
      width: '150px',
      scopedSlots: { customRender: 'action' }
    }
  ]
  export default {
    name:'a'+ Date.now(),
    components:{
      STable
    },
    data(){
      this.columns = columns
      this.searchArr = searchArr
      return{
        // 查询参数
        queryParam: {},
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          const requestParameters = Object.assign({}, parameter, this.queryParam)
          return getdesignPlan(requestParameters)
            .then(res => {
              return res
            })
        },
        selectedRowKeys:'',
        selectedRows:'',
        confirmLoading:false,
        total:{},
        form:{
          name:'',
          status:'',
          total:{},
        },
        visible:false
      }
    },
    computed: {
      rowSelection() {
        return {
          selectedRowKeys: this.selectedRowKeys,
          selectedRows: this.selectedRows,   // 当前行所有数据
          onChange: this.onSelectChange
        }
      }
    },
    created() {
      this.getTotal()
    },
    methods:{
      getTotal(){
        getTotal().then((res)=>{
          this.total = res
        })
      },
      onSelectChange(selectedRowKeys, selectedRows) {
        console.log(selectedRowKeys)
        console.log(selectedRows)
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      },
      search(values){
        this.queryParam = values
        this.$refs.table.refresh(true)
      },
      goAdd(){
        this.visible = true
      },
      handleSub(record,type){
        this.$router.push({
          path:"/project/evalution/editScore",
          query:{
            id:record.id,
            name:record.name,
            status:record.status,
            type:type
          }
        })
      },
      handleEdit(record){
        this.$router.push({
          path:"/project/design/maintain",
          query:{
            id:record.id,
            name:record.name
          }
        })
      },
      handleOk(){
        this.visible = false
        addEvaluateList(this.form).then((res)=>{
          if(res.code=='200'){
            this.$message.success("新增成功")
          }
          this.$refs.table.refresh(true)
        })
      },
      handleCancel(){
        this.visible = false
      }
    }
  }
</script>

<style scoped>
  .input{
    width:100%
  }
  .notShow{
    display:none
  }
</style>
